package com.hdy.pad.service;

import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;

public class ServiceController {
    public static final String SERVICE_PACKAGE_NAME = "com.zed.play";

    public static final String ACTION_ORDER = "com.zed.play.orderaidl";
    public static final String ACTION_VIEW_HIDE = "pad.com.invisible";
    public static final String ACTION_VIEW_SHOW = "pad.com.visible";
    public static final String ACTION_FLIP_VIEW_HIDE = "flip.pad.com.invisible";
    public static final String ACTION_FLIP_VIEW_SHOW = "flip.pad.com.visible";
    public static final String ACTION_START = "com.zed.play.start";

    public static void bindOrderService(Context context, ServiceConnection connection) {
        Intent intent = new Intent();
        intent.setAction(ACTION_ORDER);
        //从 Android 5.0开始 隐式Intent绑定服务的方式已不能使用,所以这里需要设置Service所在服务端的包名
        intent.setPackage(SERVICE_PACKAGE_NAME);
        context.bindService(intent, connection, Context.BIND_AUTO_CREATE);
    }

    public static void showView(Context context) {
        Intent intent = new Intent();
        intent.setAction(ACTION_VIEW_SHOW);
        context.sendBroadcast(intent);
    }

    public static void hideView(Context context) {
        Intent intent = new Intent();
        intent.setAction(ACTION_VIEW_HIDE);
        context.sendBroadcast(intent);
    }

}
